@extends('admin.public.admin')
@section('main')
<!-- 内容 -->
<div class="mws-panel grid_8">

		<div class="mws-panel-header">
			<span><i class="icon-table"></i> 商品评论列表</span>
		</div>

        <div class="mws-panel-body no-padding">
            	<div id="DataTables_Table_1_wrapper" class="dataTables_wrapper" role="grid">

               <form method="get" action="/admin/comment">

            		  <div id="DataTables_Table_1_length" class="dataTables_length">
               
              			<label>显示 
  	                        <select size="1" name="count" aria-controls="DataTables_Table_1">
  		                        <option value="10" @if(!empty($request['count']) && $request['count'] == 10) selected @endif>10</option>
          				        		<option value="20" @if(!empty($request['count']) && $request['count'] == 20) selected @endif>20</option>
          				        		<option value="30" @if(!empty($request['count']) && $request['count'] == 30) selected @endif>30</option>
          				        		<option value="50" @if(!empty($request['count']) && $request['count'] == 50) selected @endif>50</option>
  	                        </select> 
              			条
              			</label>
            		  </div>

            <div class="dataTables_filter" id="DataTables_Table_1_filter">
                    <label>
                    	搜索: <input type="text" name="search" value="{{$request['search'] or ''}}" aria-controls="DataTables_Table_1">
                            <input type="submit" class="btn btn-success btn-xs" value="搜索">
                    </label>
            </div>
            </form>
            <table class="mws-datatable-fn mws-table dataTable" id="DataTables_Table_1" aria-describedby="DataTables_Table_1_info">
                <thead>
                    <tr role="row">
		                    <th>ID</th>
                        <th>用户名</th>
                        <th>商品名</th>
                        <th>商品图片</th>
                        <th>内容</th>
                        <th>星级</th>
                        <th>时间</th>
                        <th>状态</th>
                    </tr>
                </thead>
                <?php 
                  $num=0;
                ?>
            <tbody role="alert" aria-live="polite" aria-relevant="all">
               @foreach($data as $value)
                  <tr>
                      <td class="">{{++$num}}</td>
                      <td>{{$value['nickname']}}</td>
                      <td>{{$value['goodsname']}}</td>

                      <td>
                        <img width="200px" src="{{$value['gimg']}}" alt="">
                      </td>

                      <td>{{$value['text']}}</td>

                      <td style="color:red">{{str_repeat("★",$value['start'])}}{{str_repeat('☆',5-$value['start'])}}</td>
                      
                      <td >{{date("Y-m-d H:i:s",$value['createtime'])}}</td>

                  <td>
                     <select name="" onchange="a(this,{{$value['id']}})" id="">

                        @if($value['statu']==1)
                          <option value="0">未审核</option>
                          <option selected value="1">正常</option>
                          <option value="2">黑名单</option>

                        @elseif($value['statu']==2)
                          <option value="0">未审核</option>
                          <option value="1">正常</option>
                          <option selected value="2">黑名单</option>
                          
                        @else
                          <option selected value="0">未审核</option>
                          <option value="1">正常</option>
                          <option value="2">黑名单</option>

                        @endif

                    </select>
                </td>
        
             </tr>
        @endforeach
             </tbody>
           </table>

           <!-- 分页 -->
              <div id="page_page">
                   {!! $data->appends($request)->render()!!}
              </div>
           </div>
      </div>
</div>

<script>
  
  function a(obj,id){
    // 获取自己的值

    val=$(obj).val();

    // 发送ajax请求

    $.post("/admin/comment/ajaxStatu",{"id":id,"statu":val,"_token":'{{csrf_token()}}'},function(data){

      if (data==1) {
        alert('修改成功');
      }else{
        alert('修改失败');
      }

    })
  }
  
</script>
	@endsection